<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>vim 操作备忘 - Zexun Luo | 罗泽勋</title>
    <meta property="og:title" content="vim 操作备忘 - Zexun Luo | 罗泽勋">
    
    <meta name="twitter:card" content="summary">

    
      
    

    
      
      <meta property="description" content="1.各种插入模式
[&amp;hellip;] 2.简单的光标移动
[&amp;hellip;] 3.拷贝/粘贴
[&amp;hellip;] 4.撤销反撤销
[&amp;hellip;] 5.打开/保存/退出/改变文件（Buffer)
">
      <meta property="og:description" content="1.各种插入模式
[&amp;hellip;] 2.简单的光标移动
[&amp;hellip;] 3.拷贝/粘贴
[&amp;hellip;] 4.撤销反撤销
[&amp;hellip;] 5.打开/保存/退出/改变文件（Buffer)
">
      
    

    
    
    
    <meta name="twitter:image" content="/images/logo.png">
    
    

    

    
    

    <link rel="stylesheet" href="/css/style.css" />
    <link rel="stylesheet" href="/css/fonts.css" />
    
<link rel="stylesheet" href="/css/custom.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.0/dist/APlayer.min.css">  

  </head>

  
  <body class="post">
    <div id="pjax-content">
    <header class="masthead">
      

<h1><a href="/"><img src="/images/logo.png" alt="Zexun Luo" /></a></h1>



      <nav class="menu">
  <ul>
  
  
  <li><a href="/">主页</a></li>
  
  <li><a href="/about/">关于</a></li>
  
  <li><a href="/blog/">日志</a></li>
  
  <li><a href="/post/">技术</a></li>
  
  

  </ul>
</nav>

    </header>
    <article class="main">
      <header class="title">
      
<h1>vim 操作备忘</h1>


<h3>
2021-07-10</h3>

<hr>


      </header>



<h3 id="一存活">一、存活</h3>
<table>
<thead>
<tr>
<th style="text-align:left">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">i</td>
<td style="text-align:left">Insert 模式，按 ESC 回到 Normal 模式。</td>
</tr>
<tr>
<td style="text-align:left">x</td>
<td style="text-align:left">删除当前光标所在的一个字符。</td>
</tr>
<tr>
<td style="text-align:left">:wq</td>
<td style="text-align:left">保存退出</td>
</tr>
<tr>
<td style="text-align:left">dd</td>
<td style="text-align:left">删除当前行，并存到剪切板</td>
</tr>
<tr>
<td style="text-align:left">p</td>
<td style="text-align:left">粘贴剪切板</td>
</tr>
<tr>
<td style="text-align:left">hjkl</td>
<td style="text-align:left">左下上右</td>
</tr>
<tr>
<td style="text-align:left">:help <command></td>
<td style="text-align:left">显示相关命令的帮助</td>
</tr>
</tbody>
</table>
<h3 id="二感觉良好">二、感觉良好</h3>
<p>1.各种插入模式</p>
<table>
<thead>
<tr>
<th style="text-align:left">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">a</td>
<td style="text-align:left">在光标后插入</td>
</tr>
<tr>
<td style="text-align:left">o</td>
<td style="text-align:left">在当前行后插入一个新行</td>
</tr>
<tr>
<td style="text-align:left">O</td>
<td style="text-align:left">在当前行前插入一个新行</td>
</tr>
<tr>
<td style="text-align:left">cw</td>
<td style="text-align:left">替换从光标所在位置到一个单词结尾的字符</td>
</tr>
</tbody>
</table>
<p>2.简单的光标移动</p>
<table>
<thead>
<tr>
<th style="text-align:left">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">0</td>
<td style="text-align:left">数字零，到行头</td>
</tr>
<tr>
<td style="text-align:left">^</td>
<td style="text-align:left">到本行第一个不是 blank 字符的位置（blank 字符就是空格、tab、换行、回车等）</td>
</tr>
<tr>
<td style="text-align:left">$</td>
<td style="text-align:left">到本行行尾</td>
</tr>
<tr>
<td style="text-align:left">g_</td>
<td style="text-align:left">到本行最后一个不是 blank 字符的位置</td>
</tr>
<tr>
<td style="text-align:left">/pattern</td>
<td style="text-align:left">搜索 pattern 的字符串（多个匹配时，按 n 到下一个）</td>
</tr>
</tbody>
</table>
<p>3.拷贝/粘贴</p>
<table>
<thead>
<tr>
<th style="text-align:left">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">p</td>
<td style="text-align:left">粘贴</td>
</tr>
<tr>
<td style="text-align:left">yy</td>
<td style="text-align:left">拷贝当前行</td>
</tr>
</tbody>
</table>
<p>4.撤销反撤销</p>
<table>
<thead>
<tr>
<th style="text-align:left">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">u</td>
<td style="text-align:left">撤销</td>
</tr>
<tr>
<td style="text-align:left">ctrl-r</td>
<td style="text-align:left">反撤销</td>
</tr>
</tbody>
</table>
<p>5.打开/保存/退出/改变文件（Buffer)</p>
<table>
<thead>
<tr>
<th style="text-align:left">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">:e &lt;path/to/file&gt;</td>
<td style="text-align:left">打开一个文件</td>
</tr>
<tr>
<td style="text-align:left">:w</td>
<td style="text-align:left">保存</td>
</tr>
<tr>
<td style="text-align:left">:saveas &lt;path/to/file&gt;</td>
<td style="text-align:left">另存为</td>
</tr>
<tr>
<td style="text-align:left">:x, ZZ 或 :wq</td>
<td style="text-align:left">保存并退出(:x仅在需要时保存)</td>
</tr>
<tr>
<td style="text-align:left">:q!</td>
<td style="text-align:left">退出不保存</td>
</tr>
<tr>
<td style="text-align:left">:qa!</td>
<td style="text-align:left">强行退出所有正在编辑的文件</td>
</tr>
<tr>
<td style="text-align:left">:n， :bn</td>
<td style="text-align:left">下一个文件</td>
</tr>
<tr>
<td style="text-align:left">:bp</td>
<td style="text-align:left">上一个文件</td>
</tr>
</tbody>
</table>
<h3 id="三更好更强更快">三、更好、更强、更快</h3>
<h3 id="未完待续">未完待续</h3>


  
  <nav class="post-nav">
    <span class="nav-prev">&larr; <a href="/post/2021-6-1/">从零开始搭建个人网站——小白篇</a></span>
    <span class="nav-next"><a href="/post/2021-7-16/">开发指南-未完待续</a> &rarr;</span>
  </nav>
  <script type="text/javascript">
  document.addEventListener('keyup', function(e) {
    if (e.target.nodeName.toUpperCase() != 'BODY') return;
    var url = false;
    if (e.which == 37) {  
      
      url = '\/post\/2021-6-1\/';
      
    } else if (e.which == 39) {  
      
      url = '\/post\/2021-7-16\/';
      
    }
    if (url) window.location = url;
  });
  </script>
  
  </article>
  </div>
  <footer>
  
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="/js/jquery.pjax.js"></script>
<script src="/js/pjax.config.js"></script>

<div class="music">
<div id="player" class="aplayer"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.0/dist/APlayer.min.js"></script>  

<script type="text/javascript">
const ap = new APlayer({
    container: document.getElementById('player'),
    order: 'random',
    listFolded: true,
    listMaxHeight: 90,
    theme:	'#b7daff',
    audio: [
    {
        name: 'きこえるかしら',
        artist: '大和田りつこ',
        url: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/music/赤毛のアンOP_きこえるかしら_大和田りつこ.mp3',
        cover: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/image/赤毛のアンOP_きこえるかしら_大和田りつこ.jpeg'
      },
      {
        name: 'まっててごらん',
        artist: '大杉久美子',
        url: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/music/大杉久美子_ネリー・シュワルツ_まっててごらん.mp3',
        cover: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/image/大杉久美子_ネリー・シュワルツ_まっててごらん.png'
      },
      {
        name: 'ペリーヌ物語',
        artist: '片头曲和片尾曲',
        url: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/music/世界名作劇場_ペリーヌ物語_OP_ED.mp3',
        cover: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/image/世界名作劇場_ペリーヌ物語_OP_ED.jpg'
      },
      {
        name: 'ほほえみの魔法',
        artist: 'トラップ一家物語',
        url: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/music/Trapp_Family_Story_Hohoemi_no_mahou_ほほえみの魔法_Smil.mp3',
        cover: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/image/Trapp_Family_Story_Hohoemi_no_mahou_ほほえみの魔法_Smil.jpg'
      },
      {
        name: 'It is a Small world',
        artist: 'Disney Classics',
        url: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/music/Disney_Classics_It_s_a_Small_World_It_s_a_Small.mp3',
        cover: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/image/Disney_Classics_It_s_a_Small_World_It_s_a_Small.jpg'
      },
      {
        name: 'Forrest Gump Suite',
        artist: 'Alan Silvestri',
        url: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/music/Alan_Silvestri_Forrest_Gump_Suite2.mp3',
        cover: 'https://cdn.jsdelivr.net/gh/lzxqaq/jsdelivr@master/image/Alan_Silvestri_Forrest_Gump_Suite.jpeg'
      },





  ]
});
</script>




<script async src="/js/fix-toc.js"></script>

<script async src="/js/center-img.js"></script>

<script async src="/js/right-quote.js"></script>

<script async src="/js/no-highlight.js"></script>

<script async src="/js/fix-footnote.js"></script>

<script async src="/js/math-code.js"></script>

<script async src="/js/external-link.js"></script>

<script async src="/js/alt-title.js"></script>

<script async src="/js/header-link.js"></script>



<script async src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>


  

  
  <hr>
  <div class="copyright">© <a href="/">Zexun Luo</a> 2020 - 2021</div>
  
  </footer>
  
  </body>
</html>

